package com.bodacn.keypoint.bean;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;


import com.bodacn.keypoint.R;

import java.util.List;


public class TypeGridAdapter extends BaseAdapter {

    private LayoutInflater inflater;
    private Context mContext;
    private List<String> list;

    public TypeGridAdapter(List<String> list, Context context) {
        this.inflater = LayoutInflater.from(context);
        this.mContext = context;
        this.list = list;
    }


    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHodler = null;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.activity_question_type, parent, false);
            viewHodler = new ViewHolder();
            viewHodler.textView=convertView.findViewById(R.id.item_QuestionType);
            convertView.setTag(viewHodler);
        } else {
            viewHodler = (ViewHolder) convertView.getTag();
        }

        viewHodler.textView.setText(list.get(position));
        return convertView;
    }


    class ViewHolder {
        TextView textView;

    }
}
